package cashpointer.core.interceptors;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 * Klasa wspomagajaca mierzenie czasu wykonania akcji.
 * @author wojciech topolski
 * @version 2009-03-24
 */
public class TimeInterceptor implements Interceptor {
    public void destroy() {
    }

    public void init() {
    }

    public String intercept(ActionInvocation action) throws Exception {
        long start = System.currentTimeMillis();
        String result = action.invoke();
        long stop = System.currentTimeMillis();

        System.out.println("Czas wykonania w sekundach: " + ((stop - start) / 1000) + "." + ((stop - start) % 1000));

        return result;
    }
}
